<template>
  <div id="debtindex">
    <c-title :hide="false" text="置换亿栈"></c-title>
    <div class="txt">请选择您的身份进入</div>
    <div class="bgbox bg1" @click="tourl('is_debtor')">
      <div class="left">{{ settingInfo.is_debtor || settingInfo.isset_debtor == 1 ? "债务人入口" : "债务人注册" }}</div>
      <div class="right">
        <div class="logo">
          <img src="../../assets/images/debt/debt2.png" alt="" />
        </div>
        <van-icon name="arrow" />
      </div>
    </div>
    <div class="bgbox bg2" @click="tourl('is_owner')">
      <div class="left">{{ settingInfo.is_owner || settingInfo.isset_owner == 1? "债权人入口" : "债权人注册" }}</div>
      <div class="right">
        <div class="logo">
          <img src="../../assets/images/debt/debt.png" alt="" />
        </div>
        <van-icon name="arrow" />
      </div>
    </div>
    <div class="bgbox bg3" @click="tourl('is_vip')">
      <div class="left">{{ settingInfo.is_vip || settingInfo.isset_vip == 1? "VIP入口" : "VIP注册" }}</div>
      <div class="right">
        <div class="logo">
          <img src="../../assets/images/debt/VIP.png" alt="" />
        </div>
        <van-icon name="arrow" />
      </div>
    </div>
  </div>
</template>
<script>
import { Toast } from "vant";
export default {
  data() {
    return {
      settingInfo: []
    };
  },
  activated() {
    this.getData();
  },
  methods: {
    tourl(key) {
      // 债务人 2
      if (key == "is_debtor") {
        if (this.settingInfo.is_debtor == 1 || this.settingInfo.isset_debtor == 1) {
          this.$router.push(this.fun.getUrl("debtorindex", {}));
        } else {
          this.$router.push(this.fun.getUrl("debtapply", { type: 2 }));
        }
      }
      // 债权人 1
      if (key == "is_owner") {
        if (this.settingInfo.is_owner == 1 || this.settingInfo.isset_owner == 1) {
          this.$router.push(this.fun.getUrl("creditorindex", {}));
        } else {
          this.$router.push(this.fun.getUrl("debtapply", { type: 1 }));
        }
      }

      // vip
      if (key == "is_vip") {
        if(this.is_debtor == 1 || this.settingInfo.is_owner == 1){
          // #92059 优化
          Toast('您无法申请成为VIP')
          return
        }
        if (this.settingInfo.is_vip == 1 || this.settingInfo.isset_vip == 1) {
          this.$router.push(this.fun.getUrl("vipIndex", {}));
        } else {
          if(this.settingInfo.vip_applying == 1){
            Toast('vip待审核中')
            return
          }
          this.$router.push(this.fun.getUrl("debtapply", { type: 3 }));
        }
      }
    },
    getData() {
      $http
        .get("plugin.debt-shop.frontend.debt-member.applyData", {}, "加载中")
        .then(res => {
          if (res.result === 1) {
            this.settingInfo = res.data;
          } else {
            Toast(res.msg);
          }
        })
        .catch(error => {
          console.log(error);
        });
    }
  }
};
</script>
<style lang="scss" scoped>
#debtindex {
  min-height: 100vh;
  background: #fff;
  padding: 1.41rem 1.25rem;

  .bg1 {
    background-image: url("../../assets/images/debt/debtb1.png");
  }

  .bg2 {
    background-image: url("../../assets/images/debt/debtb2.png");
  }

  .bg3 {
    background-image: url("../../assets/images/debt/VIPbg.png");
  }

  .bgbox {
    width: 100%;
    height: 6.56rem;
    box-shadow: 0 0.09rem 0.63rem 0 rgba(221, 119, 31, 0.51);
    border-radius: 0.31rem;
    background-size: cover;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.06rem 0 1.22rem;
    margin-bottom: 1.56rem;
    color: #fff;

    .right {
      height: 100%;
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 1.25rem;

      .logo {
        width: 4.5rem;
        height: 4.5rem;
        border-radius: 100%;
        margin-right: 0.88rem;

        img {
          width: 100%;
          height: 100%;
          border-radius: 100%;
        }
      }
    }

    .left {
      height: 100%;
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 1.25rem;
    }
  }

  .txt {
    font-size: 1.25rem;
    color: #333;
    font-weight: bold;
    text-align: left;
    margin-bottom: 2.44rem;
  }
}
</style>